package alpaca.core;

/**
 * Holds an instance of IServerModel to be accessed statically.
 */
public class ServerModelLocator {
	private static IServerModel serverModel;
	
	public static void setServerModel(IServerModel model) {
		if(serverModel == null) {
			serverModel = model;
		} else if(model == null) {
			serverModel = null;
		} else {
			throw new IllegalStateException("ServerModel has already been set.");
		}
	}
	
	public static IServerModel getServerModel() {
		if(serverModel != null) {
			return serverModel;
		} else {
			throw new IllegalStateException("ServerModel hasn't been set.");
		}
	}
}
